package edu.neu.cloud_factory.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import edu.neu.cloud_factory.entity.po.Order;
import edu.neu.cloud_factory.entity.po.Product;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 订单 Mapper 接口
 * </p>
 *
 * @author halozhy
 * @since 2021-07-15
 */
@Mapper
public interface OrderMapper extends BaseMapper<Order> {

    @Select("select * from t_order " +
            "left join t_product on t_order.o_product_id = t_product.p_id " +
            "right join t_bid on t_bid.b_order_id = t_order.o_id " +
            "${ew.customSqlSegment}")
    List<Order> listJoinProductJoinBid(@Param("ew") QueryWrapper ew);

    @Select("select count(*) from t_order " +
            "left join t_product on t_order.o_product_id = t_product.p_id " +
            "left join t_bid on t_bid.b_order_id = t_order.o_id " +
            "${ew.customSqlSegment}")
    int listCountJoinProductJoinBid(@Param("ew") QueryWrapper ew);

    @Select("select * from t_order " +
            "left join t_product on t_order.o_product_id = t_product.p_id " +
            "${ew.customSqlSegment}")
    List<Order> listJoinProduct(@Param("ew") QueryWrapper ew);

    @Select("select count(*) from t_order " +
            "left join t_product on t_order.o_product_id = t_product.p_id " +
            "${ew.customSqlSegment}")
    List<Order> listCountJoinProduct(@Param("ew") QueryWrapper ew);
}
